package com.szh.es.pojo;

import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

/**
 * 这是做酒店数据，自动补全的结构
 */
@Getter
@Setter
@ToString
@NoArgsConstructor
public class HotelDoc2 {
    private Long id;
    private String name;
    private String address;
    private Integer price;
    private Integer score;
    private String brand;
    private String city;
    private String starName;
    private String business;
    private String location;
    private String pic;

    /**DSL 定义的类型是：completion。想做的是：将品牌和商圈作为补全内容。**/
    private List<String> suggestion;

    public HotelDoc2(HotelEntity hotelEntity) {
        this.id = hotelEntity.getId();
        this.name = hotelEntity.getName();
        this.address = hotelEntity.getAddress();
        this.price = hotelEntity.getPrice();
        this.score = hotelEntity.getScore();
        this.brand = hotelEntity.getBrand();
        this.city = hotelEntity.getCity();
        this.starName = hotelEntity.getStarName();
        this.business = hotelEntity.getBusiness();
        this.location = hotelEntity.getLatitude() + ", " + hotelEntity.getLongitude();
        this.pic = hotelEntity.getPic();
        if (this.business.contains("/")){
            String[] split = this.business.split("/");
            this.suggestion = new ArrayList<>();
            this.suggestion.add(this.brand);

            Collections.addAll(this.suggestion,split);
        }else {
            this.suggestion = Arrays.asList(this.brand,this.business);
        }

    }
}
